using EnumDefine;
using Game.Gun;
using UnityEngine;

public class Block : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    ObjectTower m_Tower;
    Vector2Int m_coordinate;
    BlockCore m_ResData;
    public void DoFlooring()
    {
        m_ResData.m_eType = (int)BlockType.Road;
        FreshData();
    }

    public void SetMapBlock(int type)
    {
        m_ResData.m_eType = type;
        FreshData();
    }
    void FreshData()
    { 
        var render = gameObject.GetComponent<SpriteRenderer>();
        render.sprite = ResourceConfig.Instance().m_BlockProfabs[m_ResData.m_eType];
    }
    public void DoInit( int x, int y )
    {
        m_coordinate = new Vector2Int( x, y );
    }
    public void SetTower( ObjectTower tower)
    {
        m_Tower = tower;
        m_Tower.DoInit();
        m_Tower.DoEnterGame(transform.position, 0);
        m_Tower.LookAt( Map.Instance().GetEnemyHome()  );
    }

    public bool IsHaveTower()
    {
        return m_Tower != null;
    }
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
